# -*- coding: UTF-8 -*-
# Author: Damon(wuud1)
# CreateDate:
# Message:

# a = '''         102.068,97
#     RMB'''
# print a
# b = a.replace(' ', '').replace(',', '').replace('RMB', '').replace('\n', '')
# print b
# c = float(b) * 100
# print c

# my_cookies = {
#     'sap-contextid': "SID%3aANON%3apcqpdi33_CQP_33%3aal--bsHUsURzw8XTw8h3JNmIJuTnfMhzXhk3j2q--NEW",
#     "sap-appcontext": "c2FwLXNlc3Npb25pZD1TSUQlM2FBTk9OJTNhcGNxcGRpMzNfQ1FQXzMzJTNhYWwtLUVCenVJZldDVnU2MW1CNkpTaEVrVUQzc2ZNaFlDaGxiV05wTy1BVFQ%3d",
#     "SelectedMaterials": "",
#     "Order_Selected_materials": "",
#     "sap-usercontext": "sap-client=100",
#     "BIGipServercqpcn.bmwbrill.cn_pool_8443": "3528863392.64288.0000",
#     "MYSAPSSO2": "AjQxMDMBABg0ADAANAAyADkAUABBAFIAIAAgACAAIAACAAYxADAAMAADABBDAFEAUAAgACAAIAAgACAABAAYMgAwADEAOAAwADcAMgA2ADAAMgA1ADEABQAEAAAACAYAAlgACQACMQD%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHjCCARoCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA0NzQyNjExDDAKBgNVBAMTA0NRUAIHIBUJAglTWTAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTgwNzI2MDI1MTM3WjAjBgkqhkiG9w0BCQQxFgQUAWscGja36SWqroDFcHJ%21h%2fhDeLgwCQYHKoZIzjgEAwQvMC0CFAjCrM3Sx2D9wvczUSbSqkkZ%21eRSAhUAoLDaaa4v642bJ3CUL0fcAgzPY3Y%3d",
#     "lf_actionspage": "spp05_order_create.htm%3foninputprocessing(update)",
#     "ordtype_create": "",
#     "date_create": "",
#     "po_create": "",
#     "sppbasket": "",
#     "sap-ssolist": "O3I9cGNxcGRpMzNfQ1FQXzMzXzEwMF81NkU5MEFFNURDN0JENkU4Qjc3NzM4NDhBM0E4NUY0NzE0RTRBRjQz",
#     "SAP_SESSIONID_CQP_100": "X80qxBFSqjwRakGApOBrq2CEWgORPxHoo6wAFj4uVso%3d",
# }
# c = {
#     "c": "c",
# }
# for k in my_cookies:
#     c[k] = my_cookies[k]
# print c

# a = '2'
# b = "%018d" % int(a)
# print b

# a = "11002409855==数据异常"
# b = a.split('=')[0]
# print b

# import random
# print random.randint(3,5)

# a = '1/2'
# b = '2'
# d = b.split('/')[1] if len(b.split('/'))>1 else b.split('/')[0]
# print d

# from lxml import etree
# base_path = '/Users/duanmengdi/Desktop/workspace/bmw_part_price_html/'
# file_name = './demo3.html'
#
# with open(file_name, 'rb') as f:
#     res = f.read()
# html = etree.HTML(res.decode('utf8'))
# price = html.xpath(u'//td[contains(text(),"零售价")]/following-sibling::td[1]/text()')[0]
# stock_price = html.xpath(u'//td[contains(text(),"净值 (Stock)")]/following-sibling::td[1]/text()')[0]
# rush_price = html.xpath(u'//td[contains(text(),"净值 (Rush)")]/following-sibling::td[1]/text()')[0]
#
# price = float(price.replace(' ', '').replace(',', '').replace('RMB', '').replace('\n', '')) * 100
# stock_price = float(stock_price.replace(' ', '').replace(',', '').replace('RMB', '').replace('\n', '')) * 100
# rush_price = float(rush_price.replace(' ', '').replace(',', '').replace('RMB', '').replace('\n', '')) * 100
#
# if price==0.0:
#     print "haha"
#
# print price, stock_price, rush_price

# def insert_sql(table, data, db=None):
#     fields = '`' + '`,`'.join(data.keys()) + '`'
#     values = []
#     for v in data.values():
#         if v == 0:
#             v = '0'
#         elif not v:
#             v = ''
#         if type(v) == int:
#             values.append(v.__str__())
#         elif v == "now()":
#             values.append(v)
#         else:
#             values.append("'%s'" % v.replace("'", " ").replace("\\", "\\\\"))
#     print fields
#     print values
#     if db:
#         sql = 'INSERT INTO `%s`.`%s` (%s) VALUES (%s)' % (db, table, fields, ",".join(values))
#     else:
#         sql = 'INSERT INTO `%s` (%s) VALUES (%s)' % (table, fields, ",".join(values))
#     return sql

# a = {
#     'a':'1',
#     'b':'2',
#     'c':'3',
#     'd':'4',
#     'e':'5',
#     'f':'6',
#     'g':'7',
#     'h':'8',
# }
#
# sql = insert_sql("xxx", a)
#
# print sql

# a = {
#     'a':'1',
#     'b':'2',
# }
#
# b = {
#     'b': '3'
# }

# for k in b:
#     a[k] = b[k]
# print a

# a = '127.241,38'
# a.replace(',', '').replace(',')

# price = '10.086,21'
# price = float(price.replace(' ', '').replace(',', '').replace('.', '').replace('RMB', '').replace('\n', ''))
# print price

# detail_url = "https://www.dwp.bmw-brilliance.cn/sap(bD16aCZjPTEwMA==)/bc/bsp/bmw/gis_tp_par_dev/spp05_material_details.htm?if_material=32106883546"
# my_headers = {
#     "Host": "www.dwp.bmw-brilliance.cn",
#     "Authorization": "Basic NDA0MjlwYXI6MXEydzNlNHI=",
#     "Origin": "https://www.dwp.bmw-brilliance.cn",
#     "Upgrade-Insecure-Requests": "1",
#     "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
#     "Referer": "https://www.dwp.bmw-brilliance.cn/sap(bD16aCZjPTEwMA==)/bc/bsp/bmw/gis_tp_par_dev/spp05_stock_check.htm",
# }
# my_cookies = {
#     'sap-contextid': "SID%3aANON%3apcqpdi33_CQP_33%3aal--7EXL1z9yGpu2bQxQot5jos7rfMjhERkPy_uy-NEW",
#     "sap-appcontext": "c2FwLXNlc3Npb25pZD1TSUQlM2FBTk9OJTNhcGNxcGRpMzNfQ1FQXzMzJTNhYWwtLUVCenVJZldDVnU2MW1CNkpTaEVrVUQzc2ZNaFlDaGxiV05wTy1BVFQ%3d",
#     "SelectedMaterials": "",
#     "Order_Selected_materials": "",
#     "sap-usercontext": "sap-client=100",
#     "BIGipServercqpcn.bmwbrill.cn_pool_8443": "3528863392.64288.0000",
#     "MYSAPSSO2": "AjQxMDMBABg0ADAANAAyADkAUABBAFIAIAAgACAAIAACAAYxADAAMAADABBDAFEAUAAgACAAIAAgACAABAAYMgAwADEAOAAwADcAMgA2ADAAMgA1ADEABQAEAAAACAYAAlgACQACMQD%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHjCCARoCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA0NzQyNjExDDAKBgNVBAMTA0NRUAIHIBUJAglTWTAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTgwNzI2MDI1MTM3WjAjBgkqhkiG9w0BCQQxFgQUAWscGja36SWqroDFcHJ%21h%2fhDeLgwCQYHKoZIzjgEAwQvMC0CFAjCrM3Sx2D9wvczUSbSqkkZ%21eRSAhUAoLDaaa4v642bJ3CUL0fcAgzPY3Y%3d",
#     "lf_actionspage": "spp05_order_create.htm%3foninputprocessing(update)",
#     "ordtype_create": "",
#     "date_create": "",
#     "po_create": "",
#     "sppbasket": "",
#     "sap-ssolist": "O3I9cGNxcGRpMzNfQ1FQXzMzXzEwMF81NkU5MEFFNURDN0JENkU4Qjc3NzM4NDhBM0E4NUY0NzE0RTRBRjQz",
#     "SAP_SESSIONID_CQP_100": "HgiPzotMLD1a14Riv78EtSQAvhmTmxHog24AFj4uVso%3d",
# }
# import requests
# import sys
# reload(sys)
# sys.setdefaultencoding('utf-8')
#
# res = requests.get(url=detail_url, headers=my_headers, cookies=my_headers, verify=False)
# with open('./xxx.html', 'w') as f:
#     f.write(res.content.decode('utf8'))

# a = float(8880 / (888 - (888 * 0.32)))
# print a
# b = 8880 / 14.2
# print b
# c = 888*0.32
# print c, b+c










